#pragma once

#include <vector>
#include <map>
#include <string>
#include "ScriptValue.h"

extern "C" 
{
	#include <lua.h>
	#include <lauxlib.h>
}

using namespace std;

struct luaL_FunReg : public luaL_Reg
{
	luaL_FunReg(const char *funName, lua_CFunction pFunc)
	{
		name = funName;
		func = pFunc;
	}
};

class ScriptClassTemplate
{
protected:
	char szClassName[200];
	vector<luaL_FunReg> m_vLuaFunReg;
	map<string, ScriptValue> m_mLuaValueReg;

public:
	const char* GetClassNameW();

protected:
	ScriptClassTemplate();
	void Begin(const char* name);
	static int index_Setobj(lua_State* L);
	static int index_Getobj(lua_State* L);

	inline void RegFun(luaL_FunReg reg)
	{
		m_vLuaFunReg.push_back(reg);
	}

	inline void RegValue(string strName, DWORD *dwValue)
	{
		ScriptValue value(ScriptValue::VT_DWORD, sizeof(DWORD), (LPVOID)dwValue);
		m_mLuaValueReg[strName] = value;
	}

	inline void RegValue(string strName, LPSTR szValue, size_t size)
	{
		ScriptValue value(ScriptValue::VT_STRING, size, szValue);
		m_mLuaValueReg[strName] = value;
	}
};

